# import time
#
# from appium.webdriver.common.touch_action import TouchAction
# from selenium.webdriver.common.by import By
# import os
# import sys
#
# sys.path.append(os.getcwd())
# from Base import base_driver
#
#
# class TestCase:
#     private_commit = (By.ID, "org.c2h4.afei.beauty:id/tv_private_commit")  # 首次下载时app权限申请
#     auth_allowed = (By.XPATH, "//*[contains(text(), '允许')]")  # 手机弹窗允许按钮
#     guide_page = (By.ID, "org.c2h4.afei.beauty:id/image")  # 引导页
#     casual_see = (By.XPATH, "//*[contains(@text, '先随便看看')]")  # 进入App
#
#     def setup(self):
#         self.driver = base_driver.base_driver()
#
#     def teardown(self):
#         self.driver.close_app()
#         self.driver.quit()
#
#     def test_login(self):
#
#         self.driver.find_element_by_id("org.c2h4.afei.beauty:id/tv_private_commit").click()
#         try:
#             els = self.driver.find_elements_by_class_name('android.widget.Button')
#
#             for el in els:
#                 if el.text == '允许':
#                     self.driver.find_element_by_android_uiautomator('new UiSelector().text("允许")').click()
#                     break
#                 elif el.text == '始终允许':
#                     self.driver.find_element_by_android_uiautomator('new UiSelector().text("始终允许")').click()
#                     break
#                 elif el.text == '确定':
#                     self.driver.find_element_by_android_uiautomator('new UiSelector().text("确定")').click()
#                     break
#         except:
#             print('未检测到弹窗')
#         time.sleep(1)
#         for i in range(3):
#             self.driver.swipe(500, 1000, 200, 1000, 500)
#
#         self.driver.find_element_by_xpath("//*[contains(@text, '先随便看看')]").click()
#         # t = self.driver.find_element_by_xpath("//*[contains(@text, '先随便看看')]")
#         # t.click()
#         # self.driver.find_element_by_xpath("//*[contains(@text, '允许')]").click()

import os
import sys
import threading
import allure
sys.path.append(os.getcwd())
from Data import mobile_info
from Base import base_driver
from Page.jump_taobao import JumpTaobao



class TestCase:
    params = mobile_info.mobile

    def setup_class(self):
        self.drivers = []
        for param in self.params:
            try:
                driver = base_driver.base_driver(param, noreset=True)
                self.drivers.append(driver)
            except:
                pass

    def teardown_class(self):
        for driver in self.drivers:
            driver.close_app()
            driver.quit()

    @allure.feature("跳转淘宝")
    def test_jump_taobao(self):
        threads = []
        for driver in self.drivers:
            jumptaobao = JumpTaobao(driver)
            threads.append(threading.Thread(target=jumptaobao.search_product_jump, args=("雅诗兰黛", )))
        for t in threads:
            t.start()
        for t in threads:
            t.join()